package com.tt.dao;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import com.tt.bean.City;
import com.tt.bean.Province;
import com.tt.utils.GetResult;
@Repository
public class ProvinceAndCityImpl implements ProvinceAndCityDao {

	@Override
	public List getProvince() {
		List<Province> list = new ArrayList<>();
		SqlSession ss = null;
		try {
			ss = GetResult.getSqlSession();
		    list = ss.selectList("com.tt.bean.ProvinceAndCity.selectAllProvince");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			ss.close();
		}
		return list;
	}

	@Override
	public List<City> getCity(int id) {
		List<City> list = new ArrayList<>();
		SqlSession ss = null;
		try {
			ss = GetResult.getSqlSession();
		    list = ss.selectList("com.tt.bean.ProvinceAndCity.selectCity", id);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			ss.close();
		}
		return list;
	}

}
